package parttern.mediator;

public class Mediator extends AbsMediator {

    public Mediator(AbsColleague colleagueA, AbsColleague colleagueB) {
        super(colleagueA, colleagueB);
    }

    @Override
    public void AAffectB() {
        colleagueB.setNum(colleagueA.getNum() * 10);
    }

    @Override
    public void BAffectA() {
        colleagueA.setNum(colleagueB.getNum() / 10);
    }


    ///test
    public static void main(String[] args) {
        AbsColleague colleagueA = new ColleagueA();
        AbsColleague colleagueB = new ColleagueB();
        Mediator mediator = new Mediator(colleagueA, colleagueB);

        colleagueA.setNum(1000, mediator);
        System.out.println("a(1000):" + colleagueA.getNum() + " || b:" + colleagueB.getNum());
        colleagueB.setNum(100000, mediator);
        System.out.println("a:" + colleagueA.getNum() + " || b(100000):" + colleagueB.getNum());
    }
}
